<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = [88, 20, 10, 100, 50]
        let out = -1
        for (let i = 0; i < arr.length; i++) {
            // arr[i] === 10 ? document.write(`${i}`) :document.write('-1')
            console.log(arr)
            if (arr[i] === 10) {
                document.write(`第${i}元素10的下标为${i}<br>`)
            } else {
                document.write(`第${i}元素不是10，返回${out}<br>`)

            }
        }

        
        
        let flag = null
        //定义一个flag   判断正确就赋值给flag  没有就返回-1
        for (let i = 0; i < arr.length; i++) {
            if (arr[i] === 10) {
                console.log(i)
                let flag = '啦啦啦'
            }
        }
        if (flag === null) {
            console.log(-1)
        }

    </script>
</body>

</html>